//1.判断token,有token，说明
loadInitData();
function loadInitData() {
    var token = localStorage.getItem("token");
    console.log("token:"+token);
    $.ajax({
        type: "get",
        url: "/demo/index",
        headers: {'token': token},
        success: function (result) {
            console.log(result)
            var data = result.data;
            console.log("map:" + data);
            var loginCustomer = data.loginCustomer;
            if (loginCustomer != null) {
                var customerId = loginCustomer.customerId;
                var url ="/demo/order?customerId="+customerId;
                $(".head-user").hide();
                $(".user-menu").html('<li class="text"><a href='+url+'>个人中心</a></li>\n' +
                    '                 <li class="text" id="return"><button style="border: none">退出登录</button></li>');
                $(".user-info").show();
            } else {
                $(".head-user").show();
                $(".user-info").hide();
            }
            $("#return").click(function (){
                var token = localStorage.removeItem("token");
                window.location.href = "http://localhost:8080/demo/index.jsp";
            })
        }
    })
}
